package com.superteam.zzl.adapter.RecommendFragmentAdapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.superteam.zzl.activity.R;
import com.superteam.zzl.model.RecommendFragment.History;

import java.util.ArrayList;

/**
 * Created by zhang on 2017/1/11.
 */

/**
 * 推荐页面查看历史记录显示GridView适配器
 */
public class HistoryAdapter extends BaseAdapter {
    private Context context;
    private ArrayList<History> strings;

    public HistoryAdapter(Context context, ArrayList<History> strings) {
        this.context = context;
        this.strings = strings;
    }

    @Override
    public int getCount() {
        return strings.size();
    }

    @Override
    public Object getItem(int position) {
        return strings.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder vh;
        if(convertView == null){
            convertView = View.inflate(context, R.layout.recommendfragment_item_history,null);
            vh = new ViewHolder();

            vh.tv = (TextView)convertView.findViewById(R.id.tv_1_history);
            convertView.setTag(vh);
        }else{
            vh = (ViewHolder) convertView.getTag();
        }
        vh.tv.setText(strings.get(position).getName());
        return convertView;
    }

    class ViewHolder{
        TextView tv;
    }
}
